package com.huawei.appmarket.service.substance;

import android.os.Handler;
import android.os.Looper;
import android.view.View;
import android.widget.AbsListView;
import com.huawei.appgallery.foundation.service.common.protocol.AppListFragmentProtocol;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSSelector;
import com.huawei.appgallery.foundation.ui.css.CSSView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.widget.FooterView;
import java.util.ArrayList;
import java.util.List;
import o.chz;
import o.CollectCheck;

public class SubstanceDetailFragment extends BaseSubstanceDetailFragment<AppListFragmentProtocol> {
    private static List<String> ᐝ = new ArrayList();

    class c implements Runnable {
        final /* synthetic */ SubstanceDetailFragment ˎ;

        private c(SubstanceDetailFragment substanceDetailFragment) {
            this.ˎ = substanceDetailFragment;
        }

        public void run() {
            this.ˎ.ˊ.setVisibility(0);
        }
    }

    static {
        ᐝ.add("immersiveheaddlcard");
        ᐝ.add("substanceappdlheadcard");
        ᐝ.add("immersiveheadvideocard");
        ᐝ.add("immersiveheadaudiocard");
    }

    protected void י() {
        if (this.ͺˏ == 1 && this.ͺˎ != null && ॱˌ() != null && this.י != null && this.י.csSheet != null && this.ˋʻ != null) {
            CSSRule rule = new CSSSelector(this.ˋʻ).getRule(this.י.csSheet.getRootRule());
            if (rule != null) {
                CSSView.wrap(ॱˌ(), rule).render();
            }
        }
    }

    private View ॱˌ() {
        if (this.ͺˎ instanceof SubstanceListView) {
            return ((SubstanceListView) this.ͺˎ).ᐝॱ();
        }
        return null;
    }

    protected void ॱ(View view) {
        if (this.ͺˎ instanceof SubstanceListView) {
            ((SubstanceListView) this.ͺˎ).setBottomCardLayout(view);
        }
    }

    protected boolean ˊʻ() {
        return (this.י == null || CollectCheck.isEmpty(ٴ())) ? false : true;
    }

    public List<CardBean> ٴ() {
        if (this.י == null) {
            return null;
        }
        List ʻॱ = this.י.ʻॱ();
        if (CollectCheck.isEmpty(ʻॱ)) {
            return null;
        }
        return ᐝ.contains(((chz) ʻॱ.get(0)).ˏॱ()) ? ((chz) ʻॱ.get(0)).ˏ() : null;
    }

    public void onScroll(AbsListView absListView, int i, int i2, int i3) {
        super.onScroll(absListView, i, i2, i3);
        if (ˊʻ() && this.ˊ != null) {
            ॱ(i, i2, i3);
        }
    }

    private void ॱ(int i, int i2, int i3) {
        if (i == 0) {
            if (!this.ˊ.ˊ()) {
                this.ˊ.setVisibility(8);
            } else if (i + i2 >= i3 - 1) {
                this.ˊ.setVisibility(8);
            } else {
                this.ˊ.setVisibility(0);
            }
        } else if (((FooterView) this.ͺˎ.ˊॱ()).ʼ().getVisibility() == 0) {
            this.ˊ.setVisibility(0);
        } else if (i + i2 >= i3 - 1) {
            this.ˊ.ˋ();
            this.ˊ.setVisibility(8);
        } else {
            ॱـ();
        }
    }

    private void ॱـ() {
        new Handler(Looper.getMainLooper()).postDelayed(new c(), 10);
    }

    public void ˏͺ() {
        if (this.ˊ != null) {
            this.ˊ.ˋ();
        }
    }
}
